package locate

import (
	"net/http"
	"strings"
	"encoding/json"
)

func Handler(w http.ResponseWriter, r *http.Request)  {
	method := r.Method
	if method != http.MethodGet {
		w.WriteHeader(http.StatusMethodNotAllowed)
		return
	}
	content := Locate(strings.Split(r.URL.EscapedPath(), "/")[2])
	if len(content) <=0 {
		w.WriteHeader(http.StatusNotFound)
		return
	}

	b,_ := json.Marshal(content)
	w.Write(b)
}
